package DataEncryptionStandard;

import org.apache.commons.codec.binary.Hex;

public class DesTestData {

    private static final DES des = new DES();
    private final String key;
    private final String plaintext;
    private final String ciphertext;

    public DesTestData(String key, String plaintext, String ciphertext) {

        this.key = key;
        this.plaintext = plaintext;
        this.ciphertext = ciphertext;
    }

    public BitStream getPlaintext() {
        BitStream plaintextStream = null;
        try {
            byte[] plaintextByte = Hex.decodeHex(plaintext);
            plaintextStream = new BitStream(plaintextByte.length * 8, plaintextByte);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return plaintextStream;
    }

    public BitStream getCiphertext() {
        BitStream ciphertextStream = null;
        try {
            byte[] ciphertextByte = Hex.decodeHex(ciphertext);
            ciphertextStream = new BitStream(ciphertextByte.length * 8, ciphertextByte);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return ciphertextStream;
    }

    public BitStream[] getKey() {
        BitStream[] keyStreams = null;
        try {
            keyStreams = des.generateKey(Hex.decodeHex(key));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return keyStreams;
    }
}
